/*
HashRouter:有#号
BrowserRouter:没有#号
Route：设置路由与组件关联
Switch:只要匹配到一个地址不往下匹配，相当于for循环里面的break
Link:跳转页面，相当于vue里面的router-link
exact :完全匹配路由
Redirect:路由重定向
*/

import React,{lazy,Suspense} from 'react';
import {BrowserRouter as Router, Route, Switch,Redirect } from 'react-router-dom';
import {AuthRoute} from'./assets/js/utils/index';
const mainPage=lazy(()=>import('./pages/home/main'));
const goodsPage=lazy(()=>import('./pages/home/goods/classify'));
const goodsSeach=lazy(()=>import('./pages/home/goods/goodsSeach'));
const goodsDetailsNav=lazy(()=>import('./pages/home/goods/detailsNav'));
const loginIndex=lazy(()=>import('./pages/home/login/index'));
const regIndex=lazy(()=>import('./pages/home/reg/index'));
const balanceIndex=lazy(()=>import('./pages/home/balance/index'));
const balanceEnd=lazy(()=>import('./pages/home/balance/end'))
const addressIndex=lazy(()=>import('./pages/home/address/index'));
const addressAdd=lazy(()=>import('./pages/home/address/add'));
const addressMod=lazy(()=>import('./pages/home/address/mod'));
const userProfile=lazy(()=>import('./pages/uesr/profile/index'));
const orderIndex=lazy(()=>import('./pages/uesr/order/index'));
const transfer=lazy(()=>import('./pages/transfer/index'));
const orderDetail=lazy(()=>import('./pages/uesr/order/detail'));
const addReview=lazy(()=>import('./pages/uesr/order/add_review'));
const addressUserIndex=lazy(()=>import('./pages/uesr/address/index'));
const addressUserMod=lazy(()=>import('./pages/uesr/address/mod'));
const mobileIndex=lazy(()=>import('./pages/uesr/mobile/index'));
const mobpwdIndex=lazy(()=>import('./pages/uesr/mobpwd/index'));
const myfavIndex=lazy(()=>import('./pages/uesr/myfav/index'));

class RouterComponent extends React.Component{
  render(){
    return(
      <React.Fragment>
        <Router>
          <React.Fragment>
              <Suspense fallback={<React.Fragment></React.Fragment>}>
                  <Switch>
                      <Route path={window.base.config.path+'home'}  component={mainPage}></Route>
                      <Route path={window.base.config.path+'goods/classify'}  component={goodsPage} ></Route>
                      <Route path={window.base.config.path+'goods/seach'} component={goodsSeach}></Route>
                      <Route path={window.base.config.path+'goods/details'}component={goodsDetailsNav}></Route>
                      <Route path={window.base.config.path+'login/index'} component={loginIndex}></Route>
                      <Route path={window.base.config.path+'reg/index'} component={regIndex}></Route>
                      <Route path={window.base.config.path+'transfer/index'} component={transfer}></Route>
                      <Route path={window.base.config.path+'profile/index'} component={userProfile}/>
                      <AuthRoute path={window.base.config.path+'order'} component={orderIndex}/>
                      <AuthRoute path={window.base.config.path+'balance/index'} component={balanceIndex} />
                      <AuthRoute path={window.base.config.path+'balance/end'} component={balanceEnd} />
                      <AuthRoute path={window.base.config.path+'address/index'} component={addressIndex} />
                      <AuthRoute path={window.base.config.path+'address/add'} component={addressAdd}/>
                      <AuthRoute path={window.base.config.path+'address/mod'} component={addressMod}/>
                      <AuthRoute path={window.base.config.path+'orders/orderDetail'} component={orderDetail}/>
                      <AuthRoute path={window.base.config.path+'orders/addreview'} component={addReview}/>
                      <AuthRoute path={window.base.config.path+'user/address/index'} component={addressUserIndex}/>
                      <AuthRoute path={window.base.config.path+'user/address/mod'} component={addressUserMod}/>
                      <AuthRoute path={window.base.config.path+'user/mobile/index'} component={mobileIndex}/>
                      <AuthRoute path={window.base.config.path+'user/mobpwd/index'} component={mobpwdIndex}/>
                      <AuthRoute path={window.base.config.path+'user/myfav/index'} component={myfavIndex}/>
                    {/*<AuthRoute path={window.base.config.path+'user'} component={User}></AuthRoute>*/}
                    <Redirect to={window.base.config.path+'home/index'} ></Redirect>
                  </Switch>
              </Suspense>
          </React.Fragment>
        </Router>
      </React.Fragment>
    )
  }
}

export default RouterComponent;
